/*
 * Copyright (c) 2011 Jean-Marc Perronne
 * Ensisa, 12 rue des Freres Lumieres, F-68093 Mulhouse cedex
 * All rights reserved.
 *
 * The copyright of this software is owned by Werner Randelshofer. 
 * You may not use, copy or modify this software, except in  
 * accordance with the license agreement you entered into with  
 * Jean-Marc Perronne. For details see accompanying license terms. 
 */

package fr.uha.ensisa.jmp.drone.com;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;

public class TcpConnection extends ComInterface
{
	public Socket socket;
	private int port;
	
	public TcpConnection(int port) throws BadInterfaceException, SocketException, UnknownHostException
	{
		super();
		this.port = port;
		this.socket = new Socket();
	}
	
	public void connect() throws IOException
	{
		this.socket.connect(new InetSocketAddress(droneAddress, this.port));
	}
	
	public boolean isConnected()
	{
		return this.socket.isConnected();
	}
	
	public InputStream getInputStream() throws IOException
	{
		return this.socket.getInputStream();
	}

	public OutputStream getOutputStream() throws IOException
	{
		return this.socket.getOutputStream();
	}

	public void close() throws IOException
	{
		this.socket.close();
	}
}
